package com.pinyoumei.app.adapter;

import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.JD99Bean;
import com.pinyoumei.app.view.TextViewHelper.TextViewHelper;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2020-12-18.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-12-18        Administrator             新增Person类
 * 2020-12-18        Administrator             增加sex属性
 */
public class JD99Adapter extends BaseQuickAdapter<JD99Bean.ResultBean.GoodsListBean, BaseViewHolder> {
    public JD99Adapter(int layoutResId, @Nullable List<JD99Bean.ResultBean.GoodsListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, JD99Bean.ResultBean.GoodsListBean item) {
        RequestOptions placeholder = new RequestOptions().placeholder(R.mipmap.ic_error_loading);
        ImageView imageView =  helper.getView(R.id.iv_bg);

        Glide.with(mContext).load(item.getPict_url()).apply(placeholder).into(imageView);

        TextView title = helper.getView(R.id.tv_title);
        title.setText(TextViewHelper.setLeftImage(mContext,"jd",item.getTitle()));



        helper.setText(R.id.tv_qh_final_price,item.getQh_final_price()+"");
        TextView textView = helper.getView(R.id.tv_zk_final_price);
        textView.setText("¥ " + item.getZk_final_price()+"");
        textView.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); //中划线


        helper.setText(R.id.tv_sale_num,"已售" + item.getSale_num());
        helper.setText(R.id.tv_coupon_money, item.getCoupon_money()+"元券");
        helper.setText(R.id.tv_pre_commission, "最高返 ¥ " + item.getMax_save_money());
    }
}
